#! /bin/bash
export LANG=zh_CN.UTF-8
PRESTO_HOME=/export/server/presto/bin/presto


${PRESTO_HOME} --catalog hive --server 192.168.88.80:8090 --execute "
insert into hive.edu_rtp.rtp_signin
select class_id,
dt,
studying_student_count,
morning_signin_count,
(morning_signin_count / cast(studying_student_count as decimal(38,2)))
       as morning_signin_rate,
morning_late_count,
(morning_late_count / cast(studying_student_count as decimal(38,2)))
       as morning_late_rate,
morning_leave_count,
(morning_leave_count / cast(studying_student_count as decimal(38,2)))
       as morning_leave_rate,
morning_dis_count,
(morning_dis_count / cast(studying_student_count as decimal(38,2)))
       as morning_dis_rate,
afternoon_signin_count,
(afternoon_signin_count / cast(studying_student_count as decimal(38,2)))
       as afternoon_signin_rate,
afternoon_late_count,
(afternoon_late_count / cast(studying_student_count as decimal(38,2)))
       as afternoon_late_rate,
afternoon_leave_count,
(afternoon_leave_count / cast(studying_student_count as decimal(38,2)))
       as afternoon_leave_rate,
afternoon_dis_count,
(afternoon_dis_count / cast(studying_student_count as decimal(38,2)))
       as afternoon_dis_rate,
evening_signin_count,
(evening_signin_count / cast(studying_student_count as decimal(38,2)))
       as evening_signin_rate,
evening_late_count,
(evening_late_count / cast(studying_student_count as decimal(38,2)))
       as evening_late_rate,
evening_leave_count,
(evening_leave_count / cast(studying_student_count as decimal(38,2)))
       as evening_leave_rate,
evening_dis_count,
(evening_dis_count / cast(studying_student_count as decimal(38,2)))
       as evening_dis_rate
from hive.edu_dm.dm_signin_daycount;
"